package student1.copy;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

//

public class BaseDao {
	public Connection getConnection() {
		return DBUtil.getConnection();
	}

	public void close(Connection con, Statement st, ResultSet rs) {
		DBUtil.close(con, st, rs);
	}

	public int executeUpdate(String sql, Object... args) {
		Connection con = getConnection();
		PreparedStatement ps = null;
		try {
			ps = con.prepareStatement(sql);
			for (int i = 0; i < args.length; i++) {
				// args[i].getClass()==java.util.Date.class

				// if(args[i] instanceof java.util.Date)

				// {

				//

				//

				// }

				// blob

				ps.setObject(i + 1, args[i]);
			}
			return ps.executeUpdate();
		} catch (SQLException e) {
			e.printStackTrace();
			throw new RuntimeException(e);
		} finally {
			close(con, ps, null);
		}

	}
}